r programming test for given element